#include "unp.h"

void print_hex(char* des, void* start, unsigned int length)
{
    int i;
    unsigned char *p;

    printf(">>  %s [%d bytes]\n", des, length);

    p = (unsigned char*)start;
    for (i=0; i<length; i++) {
        if (i % 8 == 0) {
            if (i % 16 == 0) {
                if (i !=0) {
                    printf("\n");
                }
                printf("0x%08x:  ", (unsigned int)(p+i));
            } else {
                printf("  ");
            }
        }
        printf("%.2X ", *(p+i));
    }
    printf("\n");
}

